package com.tanner.mapreducedemo.mapjoin;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.net.URI;


/**
 * @author zhang.t.c
 * @date 2021/8/4
 */
public class TableDriver {
    public static void main(String[] args) throws Exception {
        Job job = Job.getInstance(new Configuration());

        job.setJarByClass(TableDriver.class);
        job.setMapperClass(TableMapper.class);
//        job.setReducerClass(TableReducer.class);

        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(NullWritable.class);
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(NullWritable.class);

        job.addCacheFile(new URI("file:///D:/demo/mapreduce-demo/data/reducejoin/pd.txt"));
        job.setNumReduceTasks(0);

        FileInputFormat.setInputPaths(job, new Path("D:\\demo\\mapreduce-demo\\data\\reducejoin\\order.txt"));
        FileOutputFormat.setOutputPath(job, new Path("D:\\demo\\mapreduce-demo\\output_mapjoin"));

        boolean b = job.waitForCompletion(true);
        System.exit(b ? 0 : 1);

    }
}
